package day14;


import java.util.*;

public class PlayCard {
    public void print() {
        Set<Play> set = new TreeSet<>();
        set.add(new Play("♦3", 3));
        set.add(new Play("♣3", 3));
        set.add(new Play("♥3", 3));
        set.add(new Play("♠3", 3));
        set.add(new Play("♦4", 4));
        set.add(new Play("♣4", 4));
        set.add(new Play("♥4", 4));
        set.add(new Play("♠4", 4));
        set.add(new Play("♦5", 5));
        set.add(new Play("♣5", 5));
        set.add(new Play("♥5", 5));
        set.add(new Play("♠5", 5));
        set.add(new Play("♦6", 6));
        set.add(new Play("♣6", 6));
        set.add(new Play("♥6", 6));
        set.add(new Play("♠6", 6));
        set.add(new Play("♦7", 7));
        set.add(new Play("♣7", 7));
        set.add(new Play("♥7", 7));
        set.add(new Play("♠7", 7));
        set.add(new Play("♦8", 8));
        set.add(new Play("♣8", 8));
        set.add(new Play("♥8", 8));
        set.add(new Play("♠8", 8));
        set.add(new Play("♦9", 9));
        set.add(new Play("♣9", 9));
        set.add(new Play("♥9", 9));
        set.add(new Play("♠9", 9));
        set.add(new Play("♦10", 10));
        set.add(new Play("♣10", 10));
        set.add(new Play("♥10", 10));
        set.add(new Play("♠10", 10));
        set.add(new Play("♦J", 11));
        set.add(new Play("♣J", 11));
        set.add(new Play("♥J", 11));
        set.add(new Play("♠J", 11));
        set.add(new Play("♦Q", 12));
        set.add(new Play("♣Q", 12));
        set.add(new Play("♥Q", 12));
        set.add(new Play("♠Q", 12));
        set.add(new Play("♦K", 13));
        set.add(new Play("♣K", 13));
        set.add(new Play("♥K", 13));
        set.add(new Play("♠K", 13));
        set.add(new Play("♦1", 14));
        set.add(new Play("♣1", 14));
        set.add(new Play("♥1", 14));
        set.add(new Play("♠1", 14));
        set.add(new Play("♦2", 15));
        set.add(new Play("♣2", 15));
        set.add(new Play("♥2", 15));
        set.add(new Play("♠2", 15));
        set.add(new Play("🃏", 16));
        set.add(new Play("🃏", 17));

        List list = new ArrayList(set);
        Collections.shuffle(list);


    }
}
class Play{
    String str; //存储牌的内容
    int num; //存储牌对应的数值

    public Play(String str, int num) {
        this.str = str;
        this.num = num;
    }
    public String toString(){
        return str;
    }
}


class Fight{
    public static void main(String[] args) throws InterruptedException {
        List<Play> sumList=new ArrayList<>();
        String color[]={"♠","♥","♣","♦"};
        String nums[]={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        for (String c:color){
            for (int i=0;i< nums.length;i++){
                sumList.add(new Play(c+nums[i],i+3));
            }
        }
        //存储大小王
        sumList.add(new Play("🃏",16));
        sumList.add(new Play("🃏",17));
        System.out.println(sumList);
        System.out.println("*****开始洗牌*****");
        Thread.sleep(2000);
        Collections.shuffle(sumList);
        System.out.println(sumList);
        List<Play> list1=new ArrayList<>();
        List<Play> list2=new ArrayList<>();
        List<Play> dizhu=new ArrayList<>();
        //给地主3张牌
        for (int i=0;i<3;i++){
            dizhu.add(sumList.remove(i));
        }
        for (int i=0;i<sumList.size();i++){
            if (i%3==0){
                list1.add(sumList.get(i));
            }else if (i%3==1){
                list2.add(sumList.get(i));
            }else {
                dizhu.add(sumList.get(i));
            }
        }
        Comparator<Play> com=(o1,o2)->{
            int n=o2.num- o1.num;
            if (n==0){
                n=o2.str.compareTo(o1.str);
            }
            return n;
        };
        Collections.sort(list1,com);
        Collections.sort(list2,com);
        Collections.sort(dizhu,com);
        System.out.println("农民1："+list1);
        System.out.println("农民2："+list2);
        System.out.println("地主："+dizhu);
    }
}